package com.weixing.mall.provider.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weixing.mall.provider.mapper.CategoryPropMapper;
import com.weixing.mall.provider.model.domain.CategoryProp;
import com.weixing.mall.provider.model.dto.CategoryPropDto;
import com.weixing.mall.provider.model.query.CategoryPropQuery;
import com.weixing.mall.provider.model.vo.CategoryPropVo;
import com.weixing.mall.provider.service.ICategoryPropService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName CategoryPropServiceImpl
 * @Description TODO <br/>
 * @Author gjq
 * @Modified By:
 * @Date 2019/8/7
 * @Version 1.0
 **/
/**
 * <p>
 * 商品模块-商品类目属性关联表 服务实现类
 * </p>
 *
 * @author Small
 * @since 2019-11-20
 */
@Service
public class CategoryPropServiceImpl extends ServiceImpl<CategoryPropMapper, CategoryProp> implements ICategoryPropService {

    @Override
    public void save(CategoryPropDto categoryPropDto) {
        CategoryProp categoryProp= new CategoryProp();
        BeanUtils.copyProperties(categoryPropDto,categoryProp);
        categoryProp.setIsRequired(categoryPropDto.getIsRequired().getValue());
        if (null == categoryPropDto.getId()){
            save(categoryProp);
        }else{
            updateById(categoryProp);
        }
    }

    @Override
    public List<CategoryPropVo> selectList(CategoryPropQuery categoryPropQuery) {
        return baseMapper.selectList(categoryPropQuery);
    }
}
